<?php
/**
 * Created by PhpStorm.
 * User: dehong
 * Date: 2016/9/13
 * Time: 20:22
 */
// 定义个常量，用来调用includes里面的文件
define('IN_TG',true);
// 用来指定本页内容
define('SCRIPT','active');
// 引入公共文件
require dirname(__FILE__).'/includes/common.inc.php'; // 转换成硬路径,速度更快
// 开始激活处理
if(!isset($_GET['active'])){
    _alert_back('非法操作');
}
if(isset($_GET['action']) && isset($_GET['active']) && isset($_GET['action'])=='ok'){
    $_active = addslashes($_GET['active']);
    if(_query("SELECT tg_active FROM tg_user WHERE tg_active='{$_active}'")){
        // 将tg_active设置为空
        $_sql = "UPDATE tg_user SET tg_active='' WHERE tg_active='{$_active}'";
        $_result = $GLOBALS['dbh']->exec($_sql);
        if($_result){
            $GLOBALS['dbh'] = null;
            _location('账户激活成功','login.php');
        }else{
            $GLOBALS['dbh'] = null;
            _location('账户激活失败','register.php');
        }
    }else{
        _alert_back('非法操作');
    }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php require ROOT_PATH.'includes/title.inc.php'; ?>
    <script type="text/javascript" src="js/register.js"></script>
</head>
<body>
<?php require ROOT_PATH."includes/header.inc.php"; ?>
    <div id="active">
        <h2>激活账户</h2>
        <p>本页面是为了模拟邮件功能，点击以下超链接激活您的账户</p>
        <p><a href="active.php?action=ok&amp;active=<?php echo @$_GET['active'];?>"><?php echo 'http://'.@$_SESSION['HTTP_HOST'].$_SERVER['PHP_SELF'];?>active.php?action=ok&amp;active=<?php echo @$_GET['active'];?></a></p>
    </div>
<?php require ROOT_PATH."includes/footer.inc.php"; ?>
</body>
</html>
